import { BrowserModule }                from '@angular/platform-browser';
import { FormsModule }                  from '@angular/forms';
import { HttpModule }                   from '@angular/http';

/* import { routing }                   from './app.routing';*/
import { LocationStrategy, 
  HashLocationStrategy }         from '@angular/common';
import { NgModule }                     from '@angular/core';

import { HeroData }                     from './hero-data';
import { InMemoryWebApiModule }         from 'angular2-in-memory-web-api';


import { AppComponent }                 from './app.component';
import { HeroBioComponent }             from './hero-bio.component';
import { HeroBiosComponent,
  HeroBiosAndContactsComponent } from './hero-bios.component';
import { HeroOfTheMonthComponent }      from './hero-of-the-month.component';
import { HeroContactComponent }         from './hero-contact.component';
import { HeroesBaseComponent,
  SortedHeroesComponent }        from './sorted-heroes.component';
import { HighlightDirective }           from './highlight.directive';
import { ParentFinderComponent,
  AlexComponent,
  AliceComponent,
  CarolComponent,
  ChrisComponent,
  CraigComponent,
  CathyComponent,
  BarryComponent,
  BethComponent,
  BobComponent }                 from './parent-finder.component';

const declarations = [
  AppComponent,
  HeroBiosComponent, HeroBiosAndContactsComponent, HeroBioComponent,
  HeroesBaseComponent, SortedHeroesComponent,
  HeroOfTheMonthComponent, HeroContactComponent,
  HighlightDirective,
  ParentFinderComponent,
];

const a_components = [AliceComponent, AlexComponent];

const b_components = [BarryComponent, BethComponent, BobComponent];

const c_components = [
  CarolComponent, ChrisComponent, CraigComponent,
  CathyComponent
];

/**
 * 02 外部模块配置
 * 经常在 NgModule 中需要注册提供商，而不是在应用程序根组件中。
 * 在下列两种情况下这么注册： 
 * (1) 希望服务在整个应用的每个角落都可以被被注入，或者 
 * (2) 必须在应用 启动前 注册一个全局服务。
 */

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    InMemoryWebApiModule.forRoot(HeroData)
    // routing TODO: add routes
  ],
  declarations: [
    declarations,
    a_components,
    b_components,
    c_components,
  ],
  bootstrap: [AppComponent],
  providers: [
    // 下面的例子时第 (2) 种情况下，配置一个非默认的 location strategy 的组件路由器，
    // 把它加入到 AppModule 的 providers 数组中。
    { provide: LocationStrategy, useClass: HashLocationStrategy }
  ]
})
export class AppModule { }

